<template>
  <swiper class="swiper" :options="swiperOption">
    <swiper-slide v-for="(item, index) in images" :key="index">
      <img :src="item.url" />
      <span>{{ item.swtitle }}</span>
    </swiper-slide>

    <div class="swiper-pagination" slot="pagination"></div>
    <div class="swiper-button-prev" slot="button-prev"></div>
    <div class="swiper-button-next" slot="button-next"></div>
  </swiper>
</template>

<script>
import { Swiper, SwiperSlide } from "vue-awesome-swiper";
import "swiper/css/swiper.css";

export default {
  components: {
    Swiper,
    SwiperSlide,
  },
  data() {
    return {
      images: [
        {
          url: require("../assets/16417992765640.jpg"),
          swtitle: "【中国内地游记攻略】云山的彼方，是被神眷顾的秘境天堂",
        },
        {
          url: require("../assets/16480018181847.jpg"),
          swtitle: "【中国内地游记攻略】盛夏贵州 • 一路黔行",
        },
        {
          url: require("../assets/16480023573329.jpg"),
          swtitle: "【中国内地游记攻略】云山的彼方，是被神眷顾的秘境天堂",
        },
        {
          url: require("../assets/16480026262353.jpg"),
          swtitle: "【中国内地游记攻略】云山的彼方，是被神眷顾的秘境天堂",
        },
      ],
      swiperOption: {
        delay: 1000,
        autoplay: true,
        loop: true,
        speed: 1000,
        pagination: {
          el: ".swiper-pagination",
          type: "fraction",
        },
        navigation: {
          nextEl: ".swiper-button-next",
          prevEl: ".swiper-button-prev",
        },
      },
    };
  },
};
</script>

<style lang="scss" scoped>
.swiper {
  z-index: 1;
  position: relative;
}
.swiper-container {
  width: 100%;
  height: 100%;
}

.swiper-slide {
  text-align: center;
  font-size: 18px;
  background: #fff;
  overflow: hidden;
  position: relative;
  color: white;
  span {
    position: absolute;
    bottom: 40px;
    right: 2%;
    font-weight: 700;
  }
}

.slide-inner {
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  background-size: cover;
  background-position: center;
  display: -webkit-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  -webkit-box-align: center;
  -ms-flex-align: center;
  -webkit-align-items: center;
  align-items: center;
  color: #fff;
}
img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.swiper-pagination {
  color: white;
  width: auto;
  font-size: 20px;
  position: absolute;
  right: -92%;
  bottom: 70px;
  /deep/.swiper-pagination-current {
    font-size: 43px;
  }
}
.swiper-button-prev,
.swiper-button-next {
  color: white;
  margin-left: 30px;
}
.swiper-button-next {
  margin-right: 30px;
}
</style>